package com.jd.sunny.java.collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Description:
 * @author:sunlin
 * @since:2012-12-07 10:36
 * @version:1.0.0
 */
public class TestArrays {

    public static void main(String[] args){

        // asList method,retrun a List,we can not use add and remove method to operate it
        Item[] items = new Item[20];
        List<Item> itemList = Arrays.asList(items);

        //you can also pass individual elements
        List<String> list = Arrays.asList("a","b","c","d");

        // transform list to array
        ArrayList<String> l = new ArrayList<String>();
        l.add("a");
        l.add("b");
        l.add("c");
        //use like this will throw Exception String[] s = (String[])l.toArray();
        //we should use like this
        String[]values = l.toArray(new String[l.size()]);
        System.out.println(values.length);

    }

}
